package student.aistar.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.ui.Model;
import student.aistar.mapper.PersonalCenterMapper;
import student.aistar.model.entity.Collect;
import student.aistar.model.entity.Orders;
import student.aistar.model.entity.User;
import student.aistar.service.IPersonalCenterService;

import javax.servlet.http.HttpSession;
import java.util.List;

@Service
@Transactional
public class PersonalCenterServiceImpl implements IPersonalCenterService {

    @Autowired
    private PersonalCenterMapper personalCenterMapper;

    @Override
    public List<Collect> userLike(Integer userId) {
        return personalCenterMapper.selectMyLike(userId);
    }

    @Override
    public void deleteUserLike(Integer productId, Integer userId) {
        personalCenterMapper.deleteMyLike(productId, userId);
    }

    @Override
    public User selectById(Integer UserId) {

        return personalCenterMapper.selectById(UserId);
    }

    @Override
    public void updateUserInfo(Integer userId, String userName, String sex,String userImg) {
        personalCenterMapper.updateById(userId,userName,sex,userImg);
    }

    @Override
    public User selectByName(String userName) {
        return personalCenterMapper.selectUserByName(userName);
    }

    @Override
    public int updateTelephoneByUserId(Integer userId, String userTelephone) {
        return personalCenterMapper.updateTelephone(userId,userTelephone);
    }

    @Override
    public int updateEmailByUserId(Integer userId, String userEmail) {
        return personalCenterMapper.updateEmail(userId,userEmail);
    }

    @Override
    public int updatePasswordByUserId(Integer userId, String userPassword) {
        return personalCenterMapper.updatePassword(userId,userPassword);
    }

    @Override
    public void insertProductToLike(Collect collect) {
        personalCenterMapper.insertProductToLike(collect);
    }

    @Override
    public void deleteProductToLike(Integer collectId) {
        personalCenterMapper.deleteProductToLike(collectId);
    }

    @Override
    public int selectOrdersStatusByUserId(Integer userId) {
        return personalCenterMapper.selectOrdersStatusByUserId(userId);
    }

    @Override
    public int selectOrdersStatusByUserId2(Integer userId) {
        return personalCenterMapper.selectOrdersStatusByUserId2(userId);
    }

    @Override
    public int selectCountLike(Integer userId) {
        return personalCenterMapper.selectCountLike(userId);
    }

    @Override
    public Collect selectCollectionByUserIdAndProductId(Integer userId, Integer productId) {
        return personalCenterMapper.selectCollectionByUserIdAndProductId(userId, productId);
    }

}
